@echo off
SetLocal EnableDelayedExpansion

set _get_com=REG QUERY HKLM\HARDWARE\DEVICEMAP\SERIALCOMM | find "COM" | find "DEVICEMAP" /V

set _cport=
set tmp=

for /f "tokens=3" %%a in ('REG QUERY HKLM\HARDWARE\DEVICEMAP\SERIALCOMM ^| find "COM" ^| find "DEVICEMAP" /V') do (
call:Concat %%a
)

set _cport=%_cport:~2%

echo %_cport% > comList.txt
notepad comList.txt
goto :EOF

:Concat
set _cport=%_cport%, %1
goto :EOF

EndLocal
@echo on